<?php

declare(strict_types=1);
/**
 * Created by .
 * User: luogan
 * Date: 2021/12/30
 */

namespace App\Controller\Api\v1;


use App\Controller\AbstractController;
use App\Service\DepartmentService;
use App\Validate\Api\DepartmentValidate;
use Hyperf\Di\Annotation\Inject;

class DepartmentController extends AbstractController
{

    /**
     * @Inject
     * @var DepartmentValidate
     */
    private $departmentValidate;

    /**
     * @Inject
     * @var DepartmentService
     */
    private $departmentService;

    /**
     * 列表
     * @return string
     */
    public function list():string
    {
        $data = $this->parame();
        $this->departmentValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->departmentService->list($data);
        return success('操作成功',$result);
    }

    /**
     * 新增
     * @return string
     */
    public function create():string
    {
        $data = $this->parame();
        $this->departmentValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->departmentService->create($data);
        return success('操作成功',$result);
    }

    /**
     * 更新
     * @return string
     */
    public function update():string
    {
        $data = $this->parame();
        $this->departmentValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->departmentService->update($data);
        return success('操作成功',$result);
    }

    /**
     * 详情
     * @return string
     */
    public function detail():string
    {
        $data = $this->parame();
        $this->departmentValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->departmentService->detail($data);
        return success('操作成功',$result);
    }

    /**
     * 删除
     * @return string
     */
    public function delete():string
    {
        $data = $this->parame();
        $this->departmentValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->departmentService->delete($data);
        return success('操作成功',$result);
    }
}
